<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>测试rsa</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 <script type="text/javascript" src="../util/jquery-1.12.4.min.js"></script>  
<script type="text/javascript" src="../util/security.js"></script>
</head>
<body>
	<input type="button" id="a2" value="确定">
	<input type="button" id="a3" value="确定1">
	<form action=""> 
		手机号<input type="text" id="a1">
		<input type="submit" value="提交">
	</form>
	

</body>
<script type="text/javascript">
var data1="";
var data2="";
$("#a2").click(function(){
	$.ajax({
		url:"/SST/t/a1.do",
		success:function(data){
			var data=JSON.parse(data);
			data1=data.publicZS;
			data2=data.publicMo;
			alert(typeof(data2.toString()))
		}
	});
	
	
});

$("#a3").click(function(){
	var phone = "12356";
	var en = encodeURIComponent(phone);
	phone = phone.split("").reverse().join("");
	RSAUtils.setMaxDigits(256);
	var key = new RSAUtils.getKeyPair(data1.toString(), "",
			data2.toString());//公钥
	var encrypedPwd = RSAUtils.encryptedString(key, en);
	$.ajax({
		url:"/SST/t/a2.do",
		contentType:"application/x-www-form-urlencoded; charset=utf-8",
		type:"post",
		data:{"phone":encrypedPwd},
		success:function(data){
			alert(data);
		}
	}); 
	
});

</script>
</html>